package hu.myai.model;

/**
 * Pivot is a stock top or bottom.
 *
 * @author bozbalint
 *
 */
public class PivotVO {

    private int type;

    private TickVO tick;

    public static final int HIGHER_HIGH = 2;
    public static final int LOWER_HIGH = 1;
    public static final int HIGHER_LOW = -1;
    public static final int LOWER_LOW = -2;

    public PivotVO(TickVO tick, int type) {
        if (tick == null)
            throw new RuntimeException("Tick is null");

        this.tick = tick;
        this.type = type;
    }

    /**
     * @return the type
     */
    public int getType() {
        return type;
    }

    /**
     * @param type
     *            the type to set
     */
    public void setType(int type) {
        this.type = type;
    }

    /**
     * @return the tick
     */
    public TickVO getTick() {
        return tick;
    }

    /*
     * (non-Javadoc)
     *
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((tick == null) ? 0 : tick.hashCode());
        result = prime * result + type;
        return result;
    }

    /*
     * (non-Javadoc)
     *
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        PivotVO other = (PivotVO) obj;
        if (tick == null) {
            if (other.tick != null)
                return false;
        } else if (!tick.equals(other.tick))
            return false;
        if (type != other.type)
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "[PivotVO=" + type + "," + tick.toString() + "]";
    }
}
